package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                                                                                        import com.ruoyi.common.utils.DateUtils;
            import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.ReduceConfigMapper;
import com.ruoyi.bizsys.domain.ReduceConfig;
import com.ruoyi.bizsys.service.IReduceConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 还款减免配置Service业务层处理
 *
 * @author african-loan
 * @date 2022-04-07
 */
@Service
public class ReduceConfigServiceImpl extends ServiceImpl<ReduceConfigMapper,ReduceConfig> implements IReduceConfigService {

    /**
     * 查询还款减免配置
     *
     * @param id 还款减免配置ID
     * @return 还款减免配置
     */
    @Override
    public ReduceConfig selectReduceConfigById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询还款减免配置列表
     *
     * @param reduceConfig 还款减免配置
     * @return 还款减免配置
     */
    @Override
    public List<ReduceConfig> selectReduceConfigList(ReduceConfig reduceConfig) {
        return this.list(new QueryWrapper<>(reduceConfig).last("order by id desc"));
    }

    /**
     * 新增还款减免配置
     *
     * @param reduceConfig 还款减免配置
     * @return 结果
     */
            @Override
    public int insertReduceConfig(ReduceConfig reduceConfig) {
                                                                                                                                                                                                                                                                reduceConfig.setCreateTime(DateUtils.getNowDate());
                                                                                        return baseMapper.insert(reduceConfig);
    }

    /**
     * 修改还款减免配置
     *
     * @param reduceConfig 还款减免配置
     * @return 结果
     */
            @Override
    public int updateReduceConfig(ReduceConfig reduceConfig) {
                                                                                                                                                                                                                                                                                                        reduceConfig.setUpdateTime(DateUtils.getNowDate());
                                                return baseMapper.updateById(reduceConfig);
    }

    /**
     * 批量删除还款减免配置
     *
     * @param ids 需要删除的还款减免配置ID
     * @return 结果
     */
            @Override
    public int deleteReduceConfigByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除还款减免配置信息
     *
     * @param id 还款减免配置ID
     * @return 结果
     */
    @Override
    public int deleteReduceConfigById(Long id) {
        return baseMapper.deleteById(id);
    }

}
